import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

const constantRoutes = [
  { path: "/", redirect: "/login/roleChoose" },
  { path: '/login/role/:loginType' ,name: 'LoginView' ,component: () => import('@/views/loginView/login') },
  { path: '/login/roleChoose' ,name: 'RoleLoginView' ,component: () => import('@/views/loginView/role') },
  { path: '/login/forgetPwd' ,name: 'RoleLoginView' ,component: () => import('@/views/loginView/forgetPwd') },

  { path: '/main', name: 'ViewMain', component: () => import('@/views/mainView/index'), redirect: '/main/todo',
    children: [
      { path: 'todo' ,name: 'TodoViewMain' ,component: () => import('@/views/todoView/main') },
      { path: 'product' ,name: 'ProductViewMain' ,component: () => import('@/views/productView/main') },
      { path: 'report' ,name: 'ReportViewMain' ,component: () => import('@/views/reportView/main') },
      { path: 'order' ,name: 'OrderViewMain' ,component: () => import('@/views/orderView/main') },
      { path: 'profile' ,name: 'ProfileViewMain' ,component: () => import('@/views/profileView/main') },
      { path: 'test' ,name: 'TestViewMain' ,component: () => import('@/views/testView/main') },
    ]
  },

  { path: '/todo/main' ,name: 'TodoMain' ,component: () => import('@/views/todoView/main') },

  { path: '/product/main' ,name: 'ProductViewMain' ,component: () => import('@/views/productView/main') },
  { path: '/product/search' ,name: 'ProductViewSearch' ,component: () => import('@/views/productView/search') },
  { path: '/product/scanner' ,name: 'ProductViewScanner' ,component: () => import('@/views/productView/scanner') },
  { path: '/product/choose' ,name: 'ProductViewChoose' ,component: () => import('@/views/productView/choose') },
  { path: '/product/:type/add' ,name: 'ProductViewAdd' ,component: () => import('@/views/productView/add') },
  { path: '/product/:type/info/:id' ,name: 'ProductViewInfo' ,component: () => import('@/views/productView/info') },
  { path: '/product/:type/edit/:id' ,name: 'ProductViewEdit' ,component: () => import('@/views/productView/edit') },

  { path: '/order/main' ,name: 'OrderMain' ,component: () => import('@/views/orderView/main') },
  { path: '/order/:type/info/:id' ,name: 'OrderPaymentInfo' ,component: () => import('@/views/orderView/info') },
  { path: '/order/:type/edit/:id' ,name: 'OrderPaymentEdit' ,component: () => import('@/views/orderView/edit') },
  { path: '/order/add' ,name: 'OrderPaymentAdd' ,component: () => import('@/views/orderView/add') },

  { path: '/order/success/:id' ,name: 'OrderViewSuccess' ,component: () => import('@/views/orderView/success') },

  { path: '/report/main' ,name: 'ReportMain' ,component: () => import('@/views/reportView/main') },
  { path: '/report/total' ,name: 'ReportViewTotal' ,component: () => import('@/views/reportView/total') },
  { path: '/report/order' ,name: 'ReportViewOrder' ,component: () => import('@/views/reportView/order') },

  { path: '/profile/main' ,name: 'ProfileMain' ,component: () => import('@/views/profileView/main') },
  { path: '/profile/info/:id' ,name: 'ProfileViewInfo' ,component: () => import('@/views/profileView/info') },
  { path: '/profile/edit/:id' ,name: 'ProfileViewEdit' ,component: () => import('@/views/profileView/edit') },
  { path: '/profile/add' ,name: 'ProfileViewAdd' ,component: () => import('@/views/profileView/add') },
  { path: '/profile/password/:id' ,name: 'ProfileViewPassword' ,component: () => import('@/views/profileView/password') },
  { path: '/test' ,name: 'Test' ,component: () => import('@/views/testView') }
]

//实例化VueRouter并将routes添加进去
const router = new Router({
  routes: constantRoutes,
  // mode: "history",
  // base: "/ahli/",
})

//抛出这个这个实例对象方便外部读取以及访问
export default router